package org.farng.mp3.id3;

import org.farng.mp3.InvalidTagException;
import org.farng.mp3.object.ObjectStringFixedLength;
import org.farng.mp3.object.ObjectStringNullTerminated;
import org.farng.mp3.object.ObjectStringSizeTerminated;

import java.io.IOException;


/**
 * Title: Description: Copyright:    Copyright (c) 2002 Company:
 *
 * @author Eric Farng
 * @version $Revision: 1.3 $
 */
public class FrameBodyLINK extends AbstractID3v2FrameBody {
    /**
     * Creates a new FrameBodyLINK object.
     */
    public FrameBodyLINK() {
        //        this.setObject("Frame Identifier", "");
        //        this.setObject("URL", "");
        //        this.setObject("ID and Additional Data", "");
    }

    public FrameBodyLINK(FrameBodyLINK body) {
        super(body);
    }

    /**
     * Creates a new FrameBodyLINK object.
     *
     * @param frameIdentifier DOCUMENT ME!
     * @param url DOCUMENT ME!
     * @param additionalData DOCUMENT ME!
     */
    public FrameBodyLINK(String frameIdentifier, String url, String additionalData) {
        this.setObject("Frame Identifier", frameIdentifier);
        this.setObject("URL", url);
        this.setObject("ID and Additional Data", additionalData);
    }

    /**
     * Creates a new FrameBodyLINK object.
     *
     * @param file DOCUMENT ME!
     *
     * @throws IOException DOCUMENT ME!
     * @throws InvalidTagException DOCUMENT ME!
     */
    public FrameBodyLINK(java.io.RandomAccessFile file)
                  throws IOException, InvalidTagException {
        this.read(file);
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getAdditionalData() {
        return (String) getObject("ID and Additional Data");
    }

    /**
     * DOCUMENT ME!
     *
     * @param additionalData DOCUMENT ME!
     */
    public void getAdditionalData(String additionalData) {
        setObject("ID and Additional Data", additionalData);
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getFrameIdentifier() {
        return (String) getObject("Frame Identifier");
    }

    /**
     * DOCUMENT ME!
     *
     * @param frameIdentifier DOCUMENT ME!
     */
    public void getFrameIdentifier(String frameIdentifier) {
        setObject("Frame Identifier", frameIdentifier);
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getIdentifier() {
        return "LINK" + ((char) 0) + getFrameIdentifier() + ((char) 0) + getAdditionalData();
    }

    /**
     * DOCUMENT ME!
     */
    protected void setupObjectList() {
        objectList.add(new ObjectStringFixedLength("Frame Identifier", 4));
        objectList.add(new ObjectStringNullTerminated("URL"));
        objectList.add(new ObjectStringSizeTerminated("ID and Additional Data"));
    }
}